package letsjava.batch;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Scanner;

import letsjava.db.NSTable;

public class DB {

	public void sql(String sql) throws SQLException {
		NSTable db = NSTable.getTable("test", "student");
		Scanner sca = new Scanner(System.in);
		while (true) {
			try {
				System.out.print("sql>");
				String sql2 = sca.nextLine();

				if ("exit".equals(sql2)) {
					System.out.println("sql>bye");
					break;
				}
				if(sql2.startsWith("select")){
					System.out.println(db.query(sql2));
				}else{
					db.exec(sql2);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static void main(String[] args) throws SQLException {
		DB db = new DB();
		db.sql("select * from student");
	}
}
